Release 10.1A: OpenEdge Development:
ProDataSets
Sample procedure: adding REPOSITION and SYNCHRONIZE
In Chapter 1, "Introducing the Progress DataSet," you learned about the
REPOSITIONmode for a Data-Relation. You can include this in aDATASETdefinition as a keyword at the end of the relation definition, or you can set it at run time as an attribute (true or false) on the relation.When you fill a ProDataSet,
REPOSITIONmode on a relation causes Progress to treat the relation as deactivated and to populate the child table with all records from its Data-Source buffer, or with all those you specify in your own Data-Source query.When you are navigating,
REPOSITIONmode causes Progress to reposition its default query on the relation to the correct record rather than reopening the query to select only that record.In this section, you will extend the
dsOrderWin.wexample to show the effect of theREPOSITIONmode on a relation. You’ll also use theSYNCHRONIZEmethod to readjust the queries the browses forOrderLinesandItemsuse.First, open
dsOrder.iand add the keywordREPOSITIONat the end of theLineItemrelation definition, as shown:
Next, get the window procedure to use the relation queries rather than the static queries the AppBuilder generates. When you created
dsOrderWin.w, you created two static browses to show the contents ofttOlineandttItem. The AppBuilder generated queries for the temp-tables for you when you did this, and associated them with preprocessor values, as shown:
You then used the
OPEN-BROWSERSpreprocessor in theLEAVEtrigger for theOrder Numberfield:
However, now you want to use the dynamic queries the ProDataSet provides for you so that you don’t have to bother using those the AppBuilder defines.
In the Main Block of
dsOrderWin.w, add these lines to associate the two browse objects with the ProDataSet relation queries:
The
OrderLinerelation query is filtered automatically forttOlinesof the currently selectedttOrder. In the case of this sample window, there is only onettOrderin the ProDataSet at a time. As you have seen from other examples, if there is more than one parent, the relation query filters for the current parent.Because of the
REPOSITIONqualifier on the relation, theLineItemrelation query doesn’t select just thettItemfor the currentttOrder. Instead, this qualifier tells Progress to leave thettItemquery open for allttItemrecords, and to reposition it to the correctttItemfor the currentttOline.The
SET-REPOSITIONED-ROWmethod tells Progress to make the selected row the fourth row in the viewport, so it’s in the middle, unless it’s already being displayed (that’s theCONDITIONALpart).In the
LEAVEtrigger foriOrderNum, you need to add statements that close the relation queries that thettOlineandttItembrowses are now using. If you don’t do this, you might see anomalous behavior when they are reopened for the ProDataSet on anotherOrder, as shown:
Remove or comment out the
OPEN-BROWSERS… preprocessor. In addition, add a line to run theSYNCHRONIZEmethod on the top-level buffer, forttOrder, as shown:
Since you’ve connected the two browses to the relation queries, you don’t need to use the static ones anymore. But because there’s no browse at the top level, for the
ttOrderfields, you need to nudge Progress and tell it to go through the steps to reopen or reposition the related queries for the currentttOrderrecord. This is whatSYNCHRONIZEdoes.When you rerun the window procedure, you can see the effect of the
REPOSITIONrelation:
![]()
You can scroll up and down in the
ItemBrowseto see that Progress has retrieved allItemsinto the temp-table. That’s whatREPOSITIONdoes atFILLtime. As you can see, the relation query the browse is using is automatically positioned to the correctttItemeach time you select attOlinerecord. That’s the part thatREPOSITIONdoes when you’re navigating a filled ProDataSet. If you want one behavior without the other, you can turn theREPOSITIONattribute on and off at run time.Just to reinforce what is happening here, try removing the
REPOSITIONkeyword fromdsOrder.iagain and rerunning the window:
![]()
At fill time, Progress is loading only
Itemsthat are in one or more of yourOrderLinesintottItem. When you view the data, it’s filteringttItemto show only the onettItemfor the currentttOlinein the browse. So there’s really nothing to browse in this case.
|
Copyright © 2005 Progress Software Corporation www.progress.com Voice: (781) 280-4000 Fax: (781) 280-4095 |